<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<!--[if IE 7]>
<html class="ie7 lt-ie10">
<![endif]-->
<!--[if IE 8]>
<html class="ie8 lt-ie10">
<![endif]-->
<!--[if IE 9]>
<html class="ie9 lt-ie10">
<![endif]-->
<!--[if gt IE 9]>
  <!-->
<html>
<!--<![endif]-->

<head>
    <meta charset="utf-8" />
    <title>登录 － 美丽说</title>
    <base href="<%=basePath%>">
    <meta name="description" content="来美丽说开启属于你的发现之旅，感受全新的购买体验吧！这里有百万粉丝的时尚大咖、热爱发现美物的生活家、一边旅行一边挖掘好货的higo海淘达人...而他们都将成为你的专属挑款师！还等什么？加入我们，发现流行，占有世界！" />
    <meta name="keywords" content="美丽说,higo,衣服,鞋子,包包,配饰,家居,美妆,搭配,团购,美丽说higo" />

    <meta http-equiv="x-ua-compatible" content="IE=edge,chrome=1" />
    <meta property="qc:admins" content="173137167465514130576375" />
    <meta name="chinaz-site-verification" content="500e4417-e595-40ac-98da-dec66c97a9e5" />
    <link rel="stylesheet" type="text/css" href="css/base.css?1607162038.1471376099" />
    <!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="css/ie6.css?1607162038.1471376099" />
    <![endif]-->
    <link rel="apple-touch-icon-precomposed" href="http://i.meilishuo.net/css/images/custom_icon_precomposed.png" />
    <link rel="icon" href="http://d04.res.meilishuo.net/pic/_o/75/6e/2f6871f198c0bd7615ffbf9a2f5f_49_48.c5.png" type="image/x-icon" />
    <link rel="stylesheet" type="text/css" href="css/login.css?1607162038.1471376099" />
    <!-- <script type="text/javascript" src="js/jquery.min.js"></script> -->
    <script src="http://code.jquery.com/jquery-1.12.3.min.js"></script>
	<!-- 引入封装了failback的接口--initGeetest -->
	<script src="js/gt.js"></script>
	<script src="admin/assets/layer/layer.js" type="text/javascript"></script>
</head>

<body>
<div class="wrap">
    <div class="reg_wrap">
        <div class="head">
            <a href="/" class="reg_logo"></a>
            <a href="/" class="welcome_txt"></a>
        </div>
        <div class="main">
            <div class="ad_wrap">
                <img src="https://s3.mogucdn.com/mlcdn/c45406/171204_2kj0kda8lih2746bjgf7933ahk53d_1200x400.jpg" width="370" height="353" /></div>
            <div class="login_form">
                <form id="loginForm">
                    <h3>
                        <a href="register.jsp">注册</a>登录美丽说</h3>
                    <div class="login_list">
                        <p class="login_box">
                            <input class="login_txt" id="mlsUser" name="account" type="text" placeholder="邮箱/手机号/昵称" />
                            <span></span>
                            <span class="user_icon"></span>
                        </p>
                    </div>
                    <div class="login_list">
                        <p class="login_box">
                            <input class="login_txt" id="password" name="loginpwd" type="password" placeholder="密码" />
                            <span></span>
                            <span class="pwd_icon"></span>
                        </p>
                    </div>
                    <!-- <div id="embed-captcha"></div>
				    <p id="wait" class="show">正在加载验证码......</p>
				    <p id="notice" class="hide">请先拖动验证码到相应位置</p> -->
                    <div class="login_list authpic ">
                    	<div id="popup-captcha"></div>
                        <!-- <div class="login_box">
                            <p class="notice_title">请点击下方图片旋转至正确位置，进行验证！</p>
                            <div class="pic_auth">
                                <input class="login_txt" id="checkcode" name="checkcode" type="text" hidden/>
                                <ul class="pic_list">
                                    <li></li>
                                    <li></li>
                                    <li></li>
                                    <li></li>
                                </ul>
                                <a class="change_pic" href="javascript:;">换一组</a></div>
                        </div> -->
                    </div>
                    <div class="loginErrorMessage none_f"></div>
                    <div class="login_btn_wrap">
                        <input type="button" id="popup-submit" onclick="login();"  class="login_btn" value="立即登录" /></div>
                    <div class="remember">
                        <input type="checkbox" name="savestate" id="savestate" checked="checked" />
                        <label for="savestate">记住我</label></div>
                    <div class="forget_pwd">
                        <a href="http://www.meilishuo.com/account/findPwd" target="_blank">忘记密码？</a></div>
                </form>
                <div class="fast_login">
                    <h3>无需注册，即可登录</h3>
                    <div class="fast_way">
                        <a href="/qqlogin/callqq" class="qq_way"></a>
                        <a href="/connect/auth/weibo" class="sina_way"></a>
                        <a href="/connect/auth/weixin" class="weixin_way"></a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
	$(function(){
		$.ajax({
		    // 获取id，challenge，success（是否启用failback）
		    url: "/code?t=" + (new Date()).getTime(), // 加随机数防止缓存
		    type: "get",
		    dataType: "json",
		    success: function (data) {
		        // 使用initGeetest接口
		        // 参数1：配置参数
		        // 参数2：回调，回调的第一个参数验证码对象，之后可以使用它做appendTo之类的事件
		        initGeetest({
		            gt: data.gt,
		            challenge: data.challenge,
		            product: "popup", // 产品形式，包括：float，embed，popup。注意只对PC版验证码有效
		            offline: !data.success // 表示用户后台检测极验服务器是否宕机，一般不需要关注
		            // 更多配置参数请参见：http://www.geetest.com/install/sections/idx-client-sdk.html#config
		        }, handlerPopup);
		    }
		});
		
	});
	var flag=false;
	var handlerPopup = function (captchaObj) {
        // 成功的回调
        captchaObj.onSuccess(function () {
            var validate = captchaObj.getValidate();
            $.ajax({
                url: "/VerifyLogin", // 进行二次验证
                type: "post",
                dataType: "json",
                data: {
                    geetest_challenge: validate.geetest_challenge,
                    geetest_validate: validate.geetest_validate,
                    geetest_seccode: validate.geetest_seccode
                },
                success: function (data) {
                    if (data && (data.status === "success")) {
                    	flag=true;
                    }
                }
            });
        });
        /* $("#popup-submit").click(function () {
            captchaObj.show();
        }); */
        // 将验证码加到id为captcha的元素里
        captchaObj.appendTo("#popup-captcha");
        // 更多接口参考：http://www.geetest.com/install/sections/idx-client-sdk.html
    };
    
    function login(){
    	if(flag==true){
    		$.ajax({
    	        cache:true,
    	        type: "POST",
    	        url:'/users/login',
    	        data:$('#loginForm').serialize(),// 你的formid
    	        //dataType:"json",
    	        async: false,
    	        error: function(request) {
    	            alert("Connection error");
    	        },
    	        success:function(data) {
    	        	if(data!=null &&data!=""){
    	        		if(data.userstaus==-1){
    	        			layer.msg('登录失败！您的帐号已被冻结!',{icon:2,time:1000});
        	        		return;
    	        		}else if(data.userstaus==0){
    	        			layer.msg('登录失败！您的帐号暂未激活,请登录邮箱激活后再试！',{icon:3,time:1000});
        	        		return;
    	        		}
    	        		layer.msg('恭喜您，登录成功!',{icon:1,time:1000});
    	        		setTimeout(function(){//两秒后跳转  
    	                   location.href='/users/selectByPrimaryKey?type=top-cont&userid='+data.userid;
    	                },1000);
    	        	}else{
    	        		layer.msg('登录失败！请确认您的帐号或密码输入是否正确!',{icon:2,time:1000});
    	        		return;
    	        	}
    	        }
    	    });
    	}else{
    		alert("请先完成验证码验证！");
    	}
    }
</script>
</html>